package com.etc.controller;

import com.etc.entity.*;
import com.etc.service.InsertService;
import com.etc.service.SearchService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@CrossOrigin
public class InsertController {
    @Resource
    private InsertService service;

    @Resource
    private SearchService searchService;

    //楼栋添加
    @RequestMapping("consumer/building/insert")
    public CommentResult insertBuilding(@RequestBody Building building)
    {
        return service.insertBuilding(building);
    }

    //住户添加
    @RequestMapping("consumer/household/insert")
    public CommentResult insertHousehold(@RequestBody Household household)
    {
        return service.insertHousehold(household);
    }

    //维修设备信息添加
    @RequestMapping("consumer/device/insert")
    public CommentResult insertDevice(@RequestBody Device device)
    {
        return service.insertDevice(device);
    }

    //社区公告添加
    @RequestMapping("consumer/infobar/insert")
    public CommentResult insertInfobar(@RequestPart(value = "file",required = false) MultipartFile file,
                                       @RequestParam("info") String info,
                                       @RequestParam("park_id")Integer park_id,
                                       @RequestParam(value = "upload_date",required = false) String upload_date)
    {
        return service.insertInfobar(file, info, park_id,upload_date);
    }

    //业主添加
    @RequestMapping("consumer/owner/")
    public CommentResult insertOwner(@RequestBody Owner owner)
    {

        return service.insertOwner(owner);
    }
    @RequestMapping("consumer/room/insertNext")
    public CommentResult insertNext(@PathVariable("id") Integer id)
    {

        return service.insertNext(id);
    }


    //房间添加
    @RequestMapping("consumer/room/insert")
    public CommentResult insertRoom(@RequestBody Room room)
    {
        return service.insertRoom(room);
    }

    //小区添加
    @RequestMapping("consumer/park/insert")
        public CommentResult insertPark(@RequestBody Park park)
    {
        return service.insertPark(park);
    }

    //缴费信息添加
    @RequestMapping("consumer/payment/insert")
    public CommentResult insert(@RequestBody Payment payment)
    {
        return service.insertPayment(payment);
    }
}
